package com.xmall.controller.admin;

import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.table.Keyword;
import com.xmall.bean.vo.IssueList;
import com.xmall.service.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/keyword")
public class KeyWordController {

    @Autowired
    KeywordService keywordService;
    @RequestMapping("list")
    public BaseRespVo selectKeyword(Integer page, Integer limit, String keyword, String url, String sort, String order){

        IssueList<Keyword> issueList = keywordService.selectKeyword(page,limit,keyword,url,sort,order);

        return BaseRespVo.ok(issueList);

    }

    @RequestMapping("create")
    public BaseRespVo insertKeyword(@RequestBody Keyword keyword){
        System.out.println(keyword);
        Keyword keyword1 = keywordService.insertKeyword(keyword);
        return BaseRespVo.ok(keyword1);
    }

    @RequestMapping("update")
public BaseRespVo updateKeyword(@RequestBody Keyword keyword){

        Keyword keyword1 = keywordService.updateKeyword(keyword);
        return BaseRespVo.ok(keyword);
    }

    @RequestMapping("delete")
    public BaseRespVo deleteKeyword(@RequestBody Keyword keyword){

        Integer integer = keywordService.deleteKeyword(keyword);

        return BaseRespVo.ok(integer);

    }
}
